# coding=utf-8
"""
Author: Mr.夏末
@Function: 关联的使用原理讲解
"""
from class11.webkeys import Web

web = Web()
web.relation_dict['text'] = '4888896415338634'
web.saveparams('a','b')
print(web.relation_dict)

# web.saveparams('ccc','{a}')
# print(web.relation_dict)

# 算法原理，不管你传了什么参数，只要里面有符合这样规则的字符串，我都替换为关联字典里面键的值
# 规则是{key}
params = ['ccc','{a}','r6yuf7{text}66666']
for key in web.relation_dict:
    # 遍历所有的键
    for i in range(len(params)):
        params[i] = params[i].replace('{'+str(key)+'}',str(web.relation_dict.get(key)))
print(params)